package com.kunbo.cn.entity.system.user;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.JoinColumn;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.kunbo.cn.entity.system.Menu;


@Entity
@Table(name="db_system_user_position")
public class Position {

	@Id @Column(name="id")
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	int id;	
	
	String text;
	String remark;//角色描述
	
	@ManyToMany(cascade=CascadeType.PERSIST,fetch=FetchType.EAGER)
    @JoinTable(
      name="position_menu_rel",
      joinColumns=@JoinColumn(name="position_id", referencedColumnName="id"),
      inverseJoinColumns=@JoinColumn(name="menu_id", referencedColumnName="id"))
	@JsonIgnore
	private List<Menu> menus = new ArrayList<Menu>();

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public List<Menu> getMenus() {
		return menus;
	}

	public void setMenus(List<Menu> menus) {
		this.menus = menus;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public Position() {
		super();
		// TODO Auto-generated constructor stub
	}

	public Position(int id, String text) {
		super();
		this.id = id;
		this.text = text;
	}

}
